
import javax.crypto.*;
import java.security.*;
import javax.crypto.spec.*;


	class EnDeCrypt {
	
		  private static String passphrase = "Terafoot1234"; 
	
	 public static void main(String[] args) throws NoSuchAlgorithmException, 
	 NoSuchPaddingException, InvalidKeyException, 
	 IllegalBlockSizeException, BadPaddingException {
		
		
		 MessageDigest digest = MessageDigest.getInstance("SHA"); //MD5 or SHA
		 digest.update(passphrase.getBytes());
		 
		 //AES requires exactly 128 bits (16bytes)
		 SecretKeySpec key = new SecretKeySpec(digest.digest(), 0, 16, "AES");
		 
		 Cipher aes = Cipher.getInstance("AES/ECB/PKCS5Padding");
		 
		 // Her krypteres password
		 aes.init(Cipher.ENCRYPT_MODE, key);
		 
		 byte[] ciphertext = aes.doFinal(passphrase.getBytes());
		 
		 System.out.println("ciphertext," + ciphertext.length + ": " + ciphertext);
		 
		 // Her dektrypteres password
		 aes.init(Cipher.DECRYPT_MODE, key);
		 
		 String cleartext = new String(aes.doFinal(ciphertext));
		 
		 System.out.println("cleartext: " + cleartext);
		 }
	}
	